#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time    : 2022/3/14 7:21 下午
# @Author  : WangZhixing
from Source.only_edge_anylize import only_edge_anylize
import os

if __name__ == '__main__':

    curpath = "/Users/wzx/Downloads/module-reverse-by-gnn/Source"

    a = "/Users/wzx/Downloads/module-reverse-by-gnn/archRecover_input_output/dependencies/"
    b = "/Users/wzx/Downloads/module-reverse-by-gnn/Metric/ground-truth"


    proname = [
        # "ArchStudio",
               "Bash",
               # "Chromium",
               # "Hadoop",
               # "ITK"
    ]

    gr = [
        # 'archstudio_gt.rsf',
          "bash_gt.rsf",
          # "chromium_gt.rsf",
          # "hadoop_gt.rsf",
          # "itk_gt.rsf"
          ]



    for i in range(len(proname)):
        pro=proname[i]
        curpath_pro = os.path.join(curpath,pro)
        grpath= os.path.join(b,gr[i])
        if not os.path.exists(curpath_pro):
            os.mkdir(curpath_pro)

        propath = os.path.join(a, pro)

        for method in os.listdir(propath):
            if not method.startswith("."):
                curpath_pro_method = os.path.join(curpath_pro,method)
                if not os.path.exists(curpath_pro_method):
                    os.mkdir(curpath_pro_method)

                methodpath = os.path.join(propath, method)
                for file in os.listdir(methodpath):
                    if file.endswith(".rsf"):
                        edgepath = os.path.join(methodpath, file)
                        print(pro + " " + method + " :")
                        only_edge_anylize(edgepath, grpath,curpath_pro_method)
